<?php
// Lay cac thong so cau hinh chung
include "../app_global.php";
// Lay cac hang so dung chung
include "../const.php";
include "dinh_const.php";
include "../connect.php";
include "../connect_ado.php";
// Ham thuc hien lay ten file va hien thi noi dung
include "../isa-lib/isa-function/isa_public_function.php";
require_once("../isa-lib/nusoap/nusoap.php");
include "../isa-lib/isa-function/prax.php";
?>

<meta http-equiv="refresh" content="90"/>
<style type="text/css">
<!--
body {
        margin-left: 0px;
        margin-top: 0px;
        margin-right: 0px;
        margin-bottom: 0px;
}
-->
</style>
<LINK href="css/main.css" type=text/css rel=stylesheet>

<SCRIPT language="JavaScript1.2">
//change 1 to another integer to alter the scroll speed. Greater is faster

var speed=1

var currentpos=0,alt=1,curpos1=0,curpos2=-1

function initialize(){

startit()

}

function scrollwindow(){

if (document.all &&

!document.getElementById)

temp=document.body.scrollTop

else

temp=window.pageYOffset

if (alt==0)

alt=2

else

alt=1

if (alt==0)

curpos1=temp

else

curpos2=temp

if (curpos1!=curpos2){

if (document.all)

currentpos=document.body.scrollTop+speed

else

currentpos=window.pageYOffset+speed

window.scroll(0,currentpos)

}

else{

currentpos=0

window.scroll(0,currentpos)

}

}

function startit(){

setInterval("scrollwindow()",50)

}

window.onload=initialize

</SCRIPT>

</head>

<body width="100%">

<?php
error_reporting(0);
#global $ado_conn;
$v_table_struct_xml_file = "xml/dinh_danh_sach_ho_so_trong_ngay.xml";
$v_table_struct_xml_string = _read_file($v_table_struct_xml_file);
# BAT DAU LAY DATA TU DB VA SHOW DATA
$row_color = 0;
echo "<table cellSpacing=1 cellPadding=2 width='100%' border='0'>";

$sql = "Exec show_crrent_date_result with recompile";
$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
$arr_all_record = $ado_conn->GetAll($sql);
$v_count = sizeof($arr_all_record);

# KET THUC LAY DATA
# Show                     height='40'
   # body noi dung can in trong 2 mang du lieu
   show_body($v_count, $arr_all_record, 1);
   # ket thuc body noi dung can in trong 2 mang du lieu
echo "</table>";
# End Show

#type_show = 1: Cac loai khac; 0 DA TRA KET QUA
function show_body($v_count, &$arr, $type_show){
     global $v_table_struct_xml_string, $v_table_struct_xml_string;
	global $row_color;
	
     if ($v_count >0){
     for($row_index = 0;$row_index< $v_count ;$row_index++){
       $ma_hs = $arr[$row_index]["ma_hs"];
       $loai_hs = $arr[$row_index]["loai_hs"];
       $status =  $arr[$row_index]["trang_thai"];
	$ngay_tra = $arr[$row_index]["da_tra_cong_dan"];
       if(($row_color % 2) == 0)
           $str_html = " <tr width='100%' class='d0'><td valign='center' align='center' width='15%' valign='top' height='40'>";
       else
           $str_html = " <tr width='100%' class='d1'><td valign='center' align='center' width='15%' valign='top' height='40'>";

       $str_html .= $ma_hs."</td>";
       $str_html .= "<td align='left' width='30%' valign='center' height='40'>";

       $v_hoten_record_xml_data = $arr[$row_index]['xml_ho_ten'];
       $table_struct_rax = new RAX();
       $table_struct_rec = new RAX();
       $table_struct_rax->open($v_table_struct_xml_string);
       $table_struct_rax->record_delim = 'col';
       $table_struct_rax->parse();
       $table_struct_rec = $table_struct_rax->readRecord();
       while ($table_struct_rec) {
              $table_struct_row = $table_struct_rec->getRow();
              $v_xml_tag_in_db = $table_struct_row["xml_tag_in_db"];
              $column_rax = new RAX();
              $column_rec = new RAX();
              $column_rax->open($v_hoten_record_xml_data);
              $column_rax->record_delim = 'data_list';
              $column_rax->parse();
              $column_rec = $column_rax->readRecord();
              $column_row = $column_rec->getRow();
              $v_value = _restore_XML_bad_char($column_row[$v_xml_tag_in_db]);
		if(!strcmp($v_value, "")){
			$table_struct_row = $table_struct_rec->getRow();
		        #$v_xml_tag_in_db = "ho_ten";
			$v_xml_tag_in_db = $table_struct_row["xml_tag_in_db_1"];
              		$column_rax = new RAX();
              		$column_rec = new RAX();
              		$column_rax->open($v_hoten_record_xml_data);
              		$column_rax->record_delim = 'data_list';
              		$column_rax->parse();
              		$column_rec = $column_rax->readRecord();
              		$column_row = $column_rec->getRow();
			$v_value = _restore_XML_bad_char($column_row[$v_xml_tag_in_db]);	
		}
		if(!strcmp($v_value, "")){
			$table_struct_row = $table_struct_rec->getRow();
		        #$v_xml_tag_in_db = "user_name";
			$v_xml_tag_in_db = $table_struct_row["xml_tag_in_db_2"];
              		$column_rax = new RAX();
              		$column_rec = new RAX();
              		$column_rax->open($v_hoten_record_xml_data);
              		$column_rax->record_delim = 'data_list';
              		$column_rax->parse();
              		$column_rec = $column_rax->readRecord();
              		$column_row = $column_rec->getRow();
			$v_value = _restore_XML_bad_char($column_row[$v_xml_tag_in_db]);	
			$v_value = _restore_XML_bad_char($column_row[$v_xml_tag_in_db]);	
		}

              $str_html .= $v_value;
              $table_struct_rec = $table_struct_rax->readRecord();
       }// End while
       $str_html .= "</td>";
       echo $str_html;
       echo "     <td align='left' width='40%' valign='center' height='40'>$loai_hs</td>
                  <td align='center' width='15%' valign='center' height='40'>";
            //if($type_show==1){
	    if($ngay_tra==""){	
                  if($status == "MOI_TIEP_NHAN")
                     echo _CONST_MOI_TIEP_NHAN;
                  elseif($status == "TU_CHOI")
                     echo _CONST_TU_CHOI;
                  elseif($status == "TRINH_KY")
                     echo _CONST_TRINH_KY;
                  elseif($status == "CAP_PHEP")
                     echo _CONST_CAP_PHEP;
                  else
                      echo _CONST_DANG_THU_LY;
            }
            else
                echo _CONST_TRA_KET_QUA;
       echo " </td>
               </tr>";
	$row_color++;
     }//End for
    }//End if
}
?>

</body>

</html>